package com.quanyan.user.utils;

import java.util.Random;

/**
 * Created by zhang on 16/11/15.
 */
public class ValidCode {

    /**
     * 生成数字验证码
     * @param n 4位验证码或者6位验证码
     * @return
     */
    public static String createValidCode(int n){
        Random random = new Random();
        Integer code = 0;
        if(n == 4){
            code = random.nextInt(9000) +1000;
        }
        if(n == 6){
            code = random.nextInt(900000) +100000;
        }
        return code.toString();
    }

    public static void main(String[] args) {
        for(int i = 0; i<= 1000; i++){
            System.out.println(createValidCode(6));
        }
    }

}
